home *** CD-ROM | disk | FTP | other *** search
-
- BCD.DOC -- Description of BCD.ASM
- =================================
-
- From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
- by Christopher L. Morgan
- Copyright (C) 1984 by The Waite Group, Inc.
-
- Purpose: BCD.ASM contains routines to convert between internal binary
- coded decimal (BCD) and other formats, both internal and external.
- _______________________________________________________________________________
-
- Contents:
- ---------
- BCDIN -- Convert from ASCII Decimal to BCD
- BCDOUT -- Convert from BCD to ASCII Decimal
- BCD2I16 -- Convert from BCD to 16-bit Binary
- I162BCD -- Convert from 16-bit Binary to BCD
- _______________________________________________________________________________
-
- Overview:
- These routines can convert external decimal representation and
- internal BCD representation, and between internal binary and internal BCD.
- The internal BCD format packs two decimal digits per byte, one per
- nibble. By using a large number of bytes, you can precisely represent
- high precision decimal numbers. These routines use 18 bytes of storage to
- handle 36-digit BCD numbers, but are easily modified to handle other sizes.
- Fixed point numbers can be handled by assigning a fixed position for
- a decimal point. For example, dollars & cents can be handled by assigning
- the decimal point so there are exactly two BCD digits to its right, which
- form the fractional part of the number.
- _______________________________________________________________________________
-
- BCDIN
-
- Function: This routine accepts a decimal number from the standard input
- device and converts it to internal BCD format.
-
- Input: The individual digits of the decimal number are received in ASCII
- through a call to a standard I/O routine. The valid digits are 0
- through 9. An ASCII code other than a digit will terminate the routine.
-
- Output: On return a 36-digit number is stored in BCD form in an
- 18-byte buffer called BCDBUFF.
-
- Registers used: No registers are modified.
-
- Segments referenced: DATAS is data segment which contains BCDBUFF.
-
- Routines called: STDIN
- _______________________________________________________________________________
-
- BCDOUT
-
- Function: This routine converts a 36-digit number stored in BCD form to
- ASCII decimal form which is sent to the standard output device.
-
- Input: Upon entry a 36-digit number is stored in an 18-byte BCD buffer
- called BCDBUFF.
-
- Output: A string of ASCII digits representing a decimal number is stored
- in a buffer called TBUFF and then sent out through a standard I/O routine.
-
- Registers used: No registers are modified.
-
- Segments referenced: DATAS is a data segment containing BCDFUFF and TBUFF.
-
- Routines called: STDOUT
- _______________________________________________________________________________
-
- BCD2IB16
-
- Function: This routine converts from internal BCD to intermal binary format.
-
- Input: Upon entry a 36-digit number is contained in am 18-byte BCD buffer
- called BCDBUFF.
-
- Output: A 16-bit binary number is returned in the DX register.
-
- Registers used: Only DX is modified. DX is used for output.
-
- Segments referenced: DATAS is a data segment containing the buffer, BCDBUFF.
- _______________________________________________________________________________
-
- IB162BCD
-
- Function: This routine converts internal 16-bit binary numbers to numbers
- stored in internal BCD format.
-
- Input: Upon entry a 16-bit binary number is in the DX register.
-
- Output: On return a 36-digit number is stored in BCD form in an 18-byte
- buffer called BCDBUFF.
-
- Registers used: No registers are modified. DX is used for input.
-
- Segments referenced: DATAS is a data segment containing BCDBUFF.
- _______________________________________________________________________________
- >>>> Physical EOF BCD.DOC <<<<<